package com.spring.ai.controller;

import com.spring.ai.assistant.KongMengAgent;
import com.spring.ai.assistant.KongMengStreamAgent;
import com.spring.ai.vo.KongMengVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;


@RestController
@RequestMapping("/api/v1")
@Tag(name = "大模型接口", description = "调用大模型 API调用")
public class KongMengAgentController {
    @Resource
    private KongMengStreamAgent kongMengStreamAgent;

    @PostMapping(value = "/chat",  produces = "text/stream;charset=utf-8")
    @Operation(summary = "调用大模型", description = "返回大模型对话内容")
    public Flux<String> chat(@RequestBody @Valid KongMengVO kongMengVO){
        Long userId = kongMengVO.getUserId();
        return kongMengStreamAgent.chat(userId, kongMengVO.getMessage());
    }

}
